<%@ page import="java.util.Vector,com.ejoysoft.wlanyz.system.User,com.ejoysoft.wlanyz.system.SysUserUnit,com.ejoysoft.wlanyz.system.Unit,
                 java.util.HashMap,com.ejoysoft.common.Constants,com.ejoysoft.common.exception.NoRightException"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="../include/jsp/head.jsp"%>
<%
try{
if(!globa.userSession.hasRight("50015"))
      throw new NoRightException("用户不具备操作该功能模块的权限，请与系统管理员联系！");
%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>权限管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="../css/main.css" rel="stylesheet" type="text/css" />
 
<script src="../include/js/list.js"></script>
<script src="../js/jquery-1.4.1.min.js"></script>
<script language="javascript">
function expand(obj, gid) {
    var oGid = eval("document.all." + gid);
    if (obj.value == "+") {
        obj.value = "-";
        if(oGid!=undefined)
        if (oGid.length == undefined)
            oGid.style.display = "";
        else
            for (var i = 0; i < oGid.length; i++)
                oGid[i].style.display = "";
    } else {
        obj.value = "+";
        if(oGid!=undefined)
        if (oGid.length == undefined)
            oGid.style.display = "none";
        else
            for (var i = 0; i < oGid.length; i++)
                oGid[i].style.display = "none";
    }
}
function rightSet() {
if (iCheckedNumber(document.all.sel) == 0) {
		alert("请先选择部门或用户进行权限分配！");
		return;
	}
    for (var i = 0; i < frm.sel.length; i++)
        if (frm.sel[i].checked)
            window.open("right_set.jsp?sel=" + frm.sel[i].value, "权限分配", "width=370,height=650,top=20,left=50,scrollbars=yes,status=yes");
} 

function expand2(obj, gid,value,userId) {
    var oGid = eval("document.all." + gid);
    if (obj.value == "+") {
    	if(gid != "g0000000000")
        	document.getElementById("fileOC"+gid).innerHTML="<img src='../images/folderopen.gif' width='16'/>";
        $("#img"+gid).attr("src","../images/_minus"+value+".gif");
        $("#userBackGround"+userId).css("background-image", "url(../images/_line4.gif)");
        obj.value = "-";
        if (oGid.length == undefined)
            oGid.style.display = "";
        else
            for (var i = 0; i < oGid.length; i++)
                oGid[i].style.display = "";
    } else {
        $("#img"+gid).attr("src","../images/_plus"+value+".gif");
    	if(gid != "g0000000000")
    		document.getElementById("fileOC"+gid).innerHTML= "<img src='../images/folderclose.gif' width='16'/>";
        obj.value = "+";
        $("#userBackGround"+userId).css("background-image", "url(../images/_line2.gif)");
        if (oGid.length == undefined)
            oGid.style.display = "none";
        else
            for (var i = 0; i < oGid.length; i++)
                oGid[i].style.display = "none";
    }
}
</script>
</head>


<body>
<form id=frm name=frm method="post" action="">

<table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><img src="../images/ri_list.jpg" width="14" height="14" align="absbottom" />&nbsp;您现在所在的位置：<font color="#0e7cc9">系统配置</font> &gt; 权限管理 </td>
  </tr>
</table>
<br>
<table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">

  <tr>
    <td width="6%" class="listtit1"  style="border-left:1px solid #32a4ea;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>&nbsp;权限管理</td>
        <td valign="top" align="right"onClick="rightSet()" style="padding: 0px;cursor:hand"><img src="../images/mid.gif" height="16" />权限分配</td> 
      </tr>
    </table></td>
    </tr>
    
     <tr>
  <td bgcolor="#FFFFFF" class="listd" style="border-left:1px solid #dddddd;border-right:1px solid #dddddd;"> &nbsp;
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
   <tr> <td > 
   	 <table width="100%" border="0" cellspacing="0" cellpadding="0">
         <tr>
           <td align="center" style="width:23px" valign="bottom">  <input style="height: 23px" type="hidden" name="b_0000000000" id="b_0000000000" value="-" />
          <img id="imgg0000000000" src="../images/_minus0.gif" width="23" onclick="expand2(document.getElementById('b_0000000000'),'g0000000000','0','');" /></td>
           <td style="height: 23px;font-size: 13px;font-weight: bold;" class="a0" valign="bottom"><span id="fileOCg0000000000"><img style="margin-bottom: 0px" src="../images/folder2.gif" width="16"/></span>&nbsp;&nbsp;&nbsp;&nbsp;部门列表</td>
        </tr>
      </table>
    </td>
   </tr>
     <tr>
      <td> 
       <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" id="g0000000000" style="display:block">
           <tr> 
           		<td align="center" style="width:23px">&nbsp;</td>
                <td  valign="top" >
                  <%
                     User user = new User(globa);
                    //获得所有用户并分组
                    HashMap allUsers = user.getUnitAllUser(" ORDER BY strUnitId  ASC");
                  	String unitId = "";
                  	if(globa.userSession.getStrUnitId()!= null && globa.userSession.getStrUnitId().length >0)
                  		unitId = globa.userSession.getStrUnitId()[0];
                    Vector userGroupTree = SysUserUnit.getUserGroupTree();  //树形目录的所有用户组向量
                    int curLevel = 1;
                    for (int i = 0; i < userGroupTree.size(); i++) {
                        Unit ug = (Unit)userGroupTree.get(i);
                        if (ug.getIntLevel() < curLevel) {   //上级用户�?
                             for (int j = ug.getIntLevel(); j < curLevel; j++) {  //输出收口标签
                %>
                    </td>
                  </tr>
                </table>
        <%
                     }
                }
        %>
        <table width="100%" border="0" align="center" cellspacing="0" cellpadding="0" id="g<%=ug.getStrParentId()%>" style="display:<%=ug.getStrParentId().equals("") ? "":"block"%>" class="td_color_1">
          <tr > 
          <% if(ug.isLastNode()){
           %>
            <td valign="top" style="width:23px">
            <%}else{ %>
              <td valign="top" background="../images/_line4.gif" style="width:23px">
            <%} %>
            <table width="100%" border="0" cellspacing="0" cellpadding="0" >
                <tr>
                  <td align="left" valign="bottom">
        <%
                if (ug.haveChild()) {   //有下级用户组
                String  tempUserId = "";
                 if (allUsers.containsKey(ug.getStrId())){
	                 Vector tempVct =((Vector)allUsers.get(ug.getStrId()));
	                 User tempUser =(User)tempVct.get(tempVct.size()-1);
	                 tempUserId = tempUser.getStrId();
                 }
        %>
       			   <input class="input3" type="hidden"  name="b_<%=ug.getStrId()%>" id="b_<%=ug.getStrId()%>" value="-" >
       		       <img id="imgg<%=ug.getStrId()%>" src="../images/_minus2.gif" width="23" onclick="expand2(document.getElementById('b_<%=ug.getStrId()%>'),'g<%=ug.getStrId()%>','2','<%=tempUserId %>');" />
       <%   
                }  
                else{ 
	         %>  
	         	 <img id="imgg<%=ug.getStrId()%>" src="../images/_line2.gif" width="23" />
	           <%     
                }
        %>        </td>
                </tr>
              </table>
            </td>
        <td align="left" style="padding-top: 0px;padding-left: 0px;margin-top: 0px">
          <table border="0" cellspacing="0" cellpadding="0" ><tr>
          <td valign="bottom" style="height: 23px">
            <%
                if (ug.haveChild()) {   //有下级用户组
       		  %>
					<span id="fileOCg<%=ug.getStrId()%>"><img alt="" src="../images/folderopen.gif" width="16"/></span>
       		  <%
       		  }else{
       		   %>
       		 	 <img id="img0000000000" alt="" src="../images/folderopen.gif" width="16" />
       		   <%} %>
   			 </td>
          <td valign="bottom" style="height: 23px">
           <input style="border:0px ;height: 23px"  name='sel'  type='radio' value='g/<%=ug.getStrId()%>'> 
          </td>
          <td valign="bottom" style="height: 23px" align="left"><%=ug.getStrUnitName()%></td>
          <td>&nbsp;</td>
         </tr>  
         </table>
          <%
                if (allUsers.containsKey(ug.getStrId())) { //有用户，显示用户
         %> 
         <table border="0" cellspacing="0" cellpadding="0" >
           
         <%
                    for (int m = 0; m < ((Vector)allUsers.get(ug.getStrId())).size(); m++) {
                        User theUser = (User)((Vector)allUsers.get(ug.getStrId())).get(m);
        %> 
         <tr>
         <% if(m < ((Vector)allUsers.get(ug.getStrId())).size()-1){%>
         <td valign="bottom" style="height: 23px;width:23px" id="<%="userBackGround"+theUser.getStrId()%>" background="../images/_line4.gif"> <img id="imgg<%=ug.getStrId()%>" src="../images/_line2.gif" width="23" /> </td>
         <%}else{ %>
         <td valign="bottom" style="height: 23px;width:23px" id="<%="userBackGround"+theUser.getStrId()%>"> <img id="imgg<%=ug.getStrId()%>" src="../images/_line2.gif" width="23" /> </td>
         <%} %>
          <td  valign="bottom" style="height: 23px"><img src="../images/user.gif" width="16"/><input style="border:0px ;height: 23px" name='sel'  type='radio' value='u/<%=theUser.getStrId()%>'></td>
          <td  valign="bottom" style="height: 23px"> <%=theUser.getStrUserId()%><font color="#FF0000">／</font><%=theUser.getStrName()%></td>
        </tr> 
        <%    }
        %>        		 
         </table>
        <%
                } %>
        <%    
                if (!ug.haveChild()) {  //没有下级用户组，直接收口
        %> 
            </td>
          </tr>
        </table>
        <%
                }
                curLevel = ug.getIntLevel();
            }
            //最后收首尾
            for (int j = 1; j < curLevel; j++) {
        %>
        	</td>
           </tr>
</table></td></tr></table>
  <%
            }}catch(Exception e){e.printStackTrace();}
        %>
               <!-- end -->  
</body>
</html>
<%@ include file="../include/jsp/footer.jsp"%>